﻿#ifndef SRC_CORE_APP_INTERFACE_H_
#define SRC_CORE_APP_INTERFACE_H_

#include "core/event_service.h"
#include <map>

namespace vz {

class AppInterface : public RefCountInterface, public MessageHandler {
 public:
  typedef scoped_refptr<AppInterface> Ptr;
  AppInterface(const std::string& app_name);

  std::string GetAppName();

  void SetEventService(EventService::Ptr event_service);

  EventService::Ptr GetEventService();

  bool PreInit();

  bool Init();

  bool Run();

  virtual bool OnPreInit() = 0;
  virtual bool OnInit() = 0;
  virtual bool OnRun() = 0;
  virtual void OnAppMessage(Message* msg) = 0;

 private:
  void OnMessage(Message* msg);

 protected:
  std::string app_name_;
  EventService::Ptr event_service_;
  Event event_;
};

}  // namespace vz

#endif
